package com.cloudbroker.openapi.manage.controller;

import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.ask.back.AskDetailBack;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.ask.back.AskFreeBack;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.ask.back.AskListQryBack;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.ask.back.AskSearchBack;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.ask.vo.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.t2service.social.AskT2BizService;
import com.cloudbroker.bcs.platform.ltb.common.ext.annotation.SaveLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import static com.cloudbroker.bcs.platform.ltb.common.util.RequestUtil.getSingleParameterMapForBody;

/**
 * Created by daibd19671 on 2016/11/18.
 */
@Controller
public class AskController {

    @Resource
    private AskT2BizService askT2BizService;

    /**
     * 添加问问记录
     * */
    @ResponseBody
    @RequestMapping("/ask_add")
    @SaveLog(remark = "提问")
    public HSBCPSBackVO ask_question_add(HttpServletRequest request, String jsonpcallback){
        AskAddForm form = getSingleParameterMapForBody(request , AskAddForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_add(form), jsonpcallback);
    }


    /**
     * 问答列表
     * */
    @ResponseBody
    @RequestMapping("/ask_list_qry")
    @SaveLog(remark = "问答列表")
    public AskListQryBack ask_list_qry(HttpServletRequest request, String jsonpcallback){
        AskListQryForm form = getSingleParameterMapForBody(request , AskListQryForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_list_qry(form), jsonpcallback);
    }


    /**
     * 问问列表
     * */
    @ResponseBody
    @RequestMapping("/leader_ask_list_qry")
    @SaveLog(remark = "投顾端查询问答列表")
    public AskListQryBack leader_ask_list_qry(HttpServletRequest request, String jsonpcallback){
        AskListQryForm form = getSingleParameterMapForBody(request , AskListQryForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_leader_ask_list_qry(form), jsonpcallback);
    }

    /**
     * 问答屏蔽
     * */
    @ResponseBody
    @RequestMapping("/ask_remove")
    @SaveLog(remark = "问答屏蔽")
    public HSBCPSBackVO ask_remove(HttpServletRequest request, String jsonpcallback){
        AskRemoveForm form = getSingleParameterMapForBody(request , AskRemoveForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_remove(form), jsonpcallback);
    }
    /**
     * 问答详情
     * */
    @ResponseBody
    @RequestMapping("/ask_detail")
    @SaveLog(remark = "问答详情")
    public AskDetailBack ask_detail(HttpServletRequest request, String jsonpcallback){
        AskDetailForm form = getSingleParameterMapForBody(request , AskDetailForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_detail(form), jsonpcallback);
    }
    /**
     * 问答详情
     * */
    @ResponseBody
    @RequestMapping("/ask_upvote")
    @SaveLog(remark = "问答点赞")
    public HSBCPSBackVO ask_upvote(HttpServletRequest request, String jsonpcallback){
        AskUpvoteForm form = getSingleParameterMapForBody(request , AskUpvoteForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_upvote(form), jsonpcallback);
    }
    /**
     * 问答详情
     * */
    @ResponseBody
    @RequestMapping("/ask_search")
    @SaveLog(remark = "问答搜索")
    public AskSearchBack ask_search(HttpServletRequest request, String jsonpcallback){
        AskSearchForm form = getSingleParameterMapForBody(request , AskSearchForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_search(form), jsonpcallback);
    }
    /**
     * 问答详情
     * */
    @ResponseBody
    @RequestMapping("/ask_free")
    @SaveLog(remark = "免费问答次数查询")
    public AskFreeBack ask_free(HttpServletRequest request, String jsonpcallback){
        AskFreeForm form = getSingleParameterMapForBody(request , AskFreeForm.class);
        return VOUtil.setJsonpResult(askT2BizService.func_ask_free(form), jsonpcallback);
    }


    /**
     * 问问列表
     * */
    @ResponseBody
    @RequestMapping("/get_leader_ask")
    @SaveLog(remark = "查询投顾问答列表")
    public AskListQryBack get_leader_ask(HttpServletRequest request, String jsonpcallback){
        LeaderAsk form = getSingleParameterMapForBody(request , LeaderAsk.class);
        return VOUtil.setJsonpResult(askT2BizService.func_get_leader_ask(form), jsonpcallback);
    }

}
